<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@page import="com.liuya.safe.policy.handler.QueryRawHandler" %>
<%@page import="com.liuya.db.sql.xml.QueryType" %>
<%@page import="com.liuya.db.sql.xml.Parameter" %>
<%@ page import="com.liuya.common.I18N" %>


<%
    I18N i18n = I18N.getWebInstance(request);
    QueryRawHandler handler = (QueryRawHandler) request.getAttribute("handler");
    QueryType query = handler.getQuery();
    Parameter[] params = query.getRawSQL().getParameter();
    String id = request.getParameter("id");
%>

<table class="ralaTable">
    <tr>
        <th><%=i18n.say("Type")%>
        </th>
        <th><%=i18n.say("Value")%>
        </th>
        <th><%=i18n.say("Action")%>
            <a href="javascript:addParam()" title="Add"><img src="${contextPath}/style/images/add.gif"/></a></th>
    </tr>
    <%
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                Parameter param = params[i];
                String[] s = handler.format(param);
    %>
    <tr>
        <td><%=s[0]%>
        </td>
        <td><%=s[1]%>
        </td>
        <td>
            <a href="javascript:moveParam('top', <%=i%>);" title="Top"><img src="${contextPath}/style/images/top.gif"/></a>
            <a href="javascript:moveParam('up', <%=i%>);" title="Up"><img src="${contextPath}/style/images/up.gif"/></a>
            <a href="javascript:moveParam('down', <%=i%>);" title="Down"><img
                    src="${contextPath}/style/images/down.gif"/></a>
            <a href="javascript:moveParam('bottom', <%=i%>);" title="Bottom"><img
                    src="${contextPath}/style/images/bottom.gif"/></a>
            <a href="javascript:editParam(<%=i %>, <%=i%>);" title="Edit"><img
                    src="${contextPath}/style/images/edit.gif"/></a>
            <a href="javascript:deleteParam(<%=i%>);" title="Delete"><img src="${contextPath}/style/images/delete.gif"/></a>
        </td>
    </tr>
    <%
            }
        }
    %>
</table>
